<?php include $this->getViewFile('/common/Head'); ?>
<body>
<?php
//阿里妈妈广告处理
$adName = GuestAdModel::model()->isAdAccess();
if(!empty($adName)){
	$alimama = GuestAdlistModel::model()->getAlimama($adName);
}
if(empty($alimama)){
	$alimama = 'mm_48515914_6072913_21280727';
}
?>
ID：<?php echo $data['goods_id'] ?><br/>
商品ID：<?php echo $data['product_id'] ?><br/>
<div style="">
    <input type="hidden" id="time_ico" value="0">
    <input type="hidden" id="product_id" value="<?php echo $data['product_id']; ?>">
    <input type="hidden" id="skip" value="0">
    <a data-type="0" biz-itemid="<?php echo $data['product_id']; ?>" data-tmpl="290x380" data-tmplid="5" data-rd="2" data-style="2" data-border="1">加载中...</a>
</div>
<script type="text/javascript">
    (function(win, doc) {
        var s = doc.createElement("script"), h = doc.getElementsByTagName("head")[0];
        if (!win.alimamatk_show) {
            s.charset = "gbk";
            s.async = true;
            s.src = "http://a.alimama.cn/tkapi.js";
            h.insertBefore(s, h.firstChild);
        }
        ;
        var o = {
            pid: "<?php echo $alimama; ?>", /*推广单元ID，用于区分不同的推广渠道*/
            appkey: "", /*通过TOP平台申请的appkey，设置后引导成交会关联appkey*/
            unid: ""/*自定义统计字段*/
        };
        win.alimamatk_onload = win.alimamatk_onload || [];
        win.alimamatk_onload.push(o);
    })(window, document);


    $(document).ready(function() {
        window.setInterval("skip_taobao()", 50);
    });
	
	var ii = 0;
	var suo = false;
    function skip_taobao() {
		if(suo){
			return true;
		}
        var is_skip = $('#skip').val();
        if (is_skip === "0") {
            if ($('#writeable_iframe_0').contents().find('a').length > 0) {
				ii = 0;
				suo = false;
                var href = $('#writeable_iframe_0').contents().find('a').attr('href');
				if(href){
					$.getJSON('<?php echo AdminBase::U("Public_Click") ?>',{id:'<?php echo $data['goods_id'] ?>',click_url:href},function(data){
						window.location.reload();
						//alert(data.info);
					});
				}else{
					window.location.reload();
				}
                $('#skip').val('1');
            }else{
				ii = ii + 1;
				if(ii > 100){
					suo = true;
					//商品不存在的可能
					$.getJSON('<?php echo AdminBase::U("Public_Click") ?>',{id:'<?php echo $data['goods_id'] ?>',click_url:'0'},function(data){
						window.location.reload();
						//alert(data.info);
					});
				}
			}
        }
    }
</script>
</body>
</html>